#include "gp2x/gl.h"

unsigned char colours[][3] = {{0, 0, 0}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {255, 255, 255}};
#define NUM_COLOURS 8

int render(int frame) {
    int c = 0;
    float y;

    switch(frame) {
    case 0:
        for(y = -0.5; y < 0.5; y += 0.1) {
            glBegin(GL_LINES);
            glColor3ubv(colours[c]);
            glVertex3f( 0.5,  y, 0.0);
            glVertex3f(-0.5,  y, 0.0);
            glEnd();

            c = (c + 1) % NUM_COLOURS;
        }
        return 1;
    case 1:
        glShadeModel(GL_FLAT);
        for(y = -0.5; y < 0.5; y += 0.1) {
            glBegin(GL_LINES);
            glColor3ubv(colours[c]);
            c = (c + 1) % NUM_COLOURS;
            glVertex3f( 0.5,  y, 0.0);
            glColor3ubv(colours[c]);
            c = (c + 1) % NUM_COLOURS;
            glVertex3f(-0.5,  y, 0.0);
            glEnd();
        }
        return 1;
    case 2:
        glShadeModel(GL_SMOOTH);
        for(y = -0.5; y < 0.5; y += 0.1) {
            glBegin(GL_LINES);
            glColor3ubv(colours[c]);
            c = (c + 1) % NUM_COLOURS;
            glVertex3f( 0.5,  y, 0.0);
            glColor3ubv(colours[c]);
            c = (c + 1) % NUM_COLOURS;
            glVertex3f(-0.5,  y, 0.0);
            glEnd();
        }
        return 0;
    default:
        return 0;
    }
}
